
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DimDate]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
 drop table [dbo].[DimDate]

GO

CREATE TABLE [dbo].[DimDate] (
	[DateKey] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL,
	[LongName] [varchar] (30) NOT NULL,
	[BigEndianShortName] [varchar] (20) NOT NULL,
	[MiddleEndianShortName] [varchar] (20) NOT NULL,
	[LittleEndianShortName] [varchar] (20) NOT NULL,
	[FullDate] [datetime] NOT NULL,
	[Year] [int] NOT NULL,
	[Month] [int] NOT NULL,
	[Day] [int] NOT NULL,
	[IsWeekDay] [varchar] (3) NOT NULL,
	[IsWeekend] [varchar] (3) NOT NULL,
	[MonthName] nvarchar (50) NOT NULL,
	[DayName] nvarchar (20) NOT NULL,
	[WeekNumber] [int] NOT NULL,
	[DayOfYear] [int] NOT NULL,

	CONSTRAINT [PK_Date] PRIMARY KEY CLUSTERED (
		   [DateKey])

)

GO

grant references, select, insert, delete, update on [dbo].[DimDate] to [db_datawriter]

GO

grant select on [dbo].[DimDate] to [public]

GO

